import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/res/lf_widget_ext.dart';
import 'package:largefriends/widgets/lf_app_bar.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:webview_flutter/webview_flutter.dart';

import '../../res/lf_color.dart';
import 'lf_browser_logic.dart';

class LfBrowserPage extends StatelessWidget {
  final logic = Get.put(LfBrowserLogic());

  LfBrowserPage({super.key});

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
        child: Scaffold(
          appBar: lfAppBar(
            leadingCallback: () {
              Get.back();
            },
            title: logic.title,
          ),
          body: Stack(
            children: [
              WebViewWidget(controller: logic.controller),
              Obx(() => logic.isLoading.isTrue
                  ? Container(
                      color: Get.theme.primaryColor,
                      height: double.infinity,
                      child: Center(
                        child: LoadingAnimationWidget.dotsTriangle(
                          color: color210215,
                          size: 40.r,
                        ),
                      ),
                    )
                  : empty)
            ],
          ),
        ),
        onWillPop: () async {
          Get.back();
          return false;
        });
  }
}
